#include "stdafx.h"
#include "Thread/AbstractApiConnection.h"
#include "Utils/Logger.h"
#include "Business/Dealing.h"
#include "Business/Cancellation.h"

void AbstractApiConnection::LogOrder(int rtn, Dealing const& dealing, std::string const& contractCode, int requestId)
{
	char const* dirction = dealing.GetDirection()== Direction::SELL ? "sell":"buy";
	char const* operation = dealing.GetOperation()== Operation::OPEN ? "open":"offset";

	LightLogger::Info(FT("Order:rtn:[%d] Business[%d] RequestId:[%d] OrderLocalId:[%d] OrderContract:[%s] Flag:[%s-%s] Price:[%.2f,%d]",
		rtn,dealing.GetBusinessId(), requestId,dealing.GetLocalId(), contractCode.c_str(),
		dirction,operation, dealing.GetOrderPrice(),dealing.GetOrderQuantity()));
}

void AbstractApiConnection::LogCancellation(int rtn, Cancellation const &cancellation,int requestId)
{
	LightLogger::Info(FT("Cancel:rtn:[%d] Business[%d] ActionLocalId:[%d] OrderLocalId:[%d] RequestId:[%d] SystemNo:[%s]",
		rtn, cancellation.GetBusinessId(), cancellation.GetCancelLocalId(),cancellation.GetOrderLocalId(),requestId,cancellation.GetSystemNo()));
}